<?php
   //引入init.php页面
   include_once('init.php');  
?>
<!DOCTYPE HTML >
<html>
 <head>
  <title> New Document </title>
  <meta charset="utf-8">
  <link rel="stylesheet" href="./css/showcar.css">
 </head>

 <body>
	<h1>购物车</h1>
	
	<table border=1 cellspacing=0 width="800px" rules="rows" frame="void">
		<tr height="40px">
			<th colspan=2>商品信息</th>
			<th>单价</th>
			<th>数量</th>
			<th>总价</th>
			<th>操作</th>
		</tr>
		<?php
		$sum=0;
		if(isset($_SESSION['goods'])){
			foreach($_SESSION['goods']as $vo){
				foreach($products as $v){
				if($vo['id']==$v['id']){
					$price=$v['price']*$vo['num'];
					$sum+=$price;
		?>
		<tr height="100px"> 
			<form action="edit.php" method="get">
			<input type="hidden"name="type" value="3">
			<input type="hidden"name="id"
			value="<?=$v['id']?>">
			<td width="15%">
				<img src="./img/<?=$v['img']?>" width="70px" >
			</td>
			<td width="35%"><span><?=$v['name']?></span></td>
			<td width="10%"><span><?=$v['price']?></span></td>
			<td width="20%">
				<a href="edit.php?type=2&id=<?=$v['id']?>"
				class="change">-</a>
				<input type="text" name="num"
				value="<?=$vo['num']?>">
				<a href="./edit.php?type=1&id=<?=$v['id']?>"
				class="change">+</a>
			</td>
			<td width="10%"><span><?=$price?></span></td>
			<td width="10%">
				<input type="submit" name="sub" value="修改">
				<a href="./delete.php<?= $v['id']?>" class="del">删除</a>
			</td>
			</form>
		</tr>
		<?php }}}}
		
		?>
		<tr height="80px">
			<td colspan=3>
				<a href="./dingdan.php?sum=<?= $sum?>" class="pay">去付款</a>
			</td>
			<td colspan=3>
				<span class="sprice">总价:<?=$sum?></span>
			</td>
		</tr>
	</table>
 </body>
</html>
